package br.com.lolprojects.lolcalc.calc;

import java.awt.List;
import java.util.ArrayList;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import br.com.lolprojects.lolcalc.util.ResponseUtil;

@Path("/damageCalc")
public class DamageCalc {

	//http://localhost:8080/lolcalc/rest/damageCalc/damage/?damage=90&armor=30&penetration=15
	
	@GET
	@Path("damage")
	@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
	public Response damageCalc(@QueryParam("damage") Integer damage,
			@QueryParam("armor") Integer armor,
			@QueryParam("penetration") Integer penetration) {
		Integer realDamage = null;
		Integer armorTmp = armor - penetration;
		if (armorTmp > 0) {
			realDamage = Math.round((damage * 100) / (100 + armorTmp));
		} else {
			realDamage = damage;
		}
		ArrayList<Integer> a = new ArrayList<Integer>();
		return ResponseUtil.responseJSON(realDamage);
	}

	//http://localhost:8080/lolcalc/rest/damageCalc/TESTE
	@GET
	@Path("/{param}")
	public Response teste(@PathParam("param") String teste) {
		System.out.println(teste);
		return Response.status(200).entity(teste).build();
	}

}
